<style>
    .layui-laypage a, .layui-laypage span{
        background-color: #f2f2f2;
    }
</style>


<script type="text/html" id="tol">
    <div>
        <div style="float:left;">桌面配置</div>
        <div style="float:right;margin-right: 50px">共有数据：<span id="zong"></span>条</div>
    </div>
</script>
<table class="layui-table" id="groupdata" lay-filter="groupdata">

</table>
<!--</div>-->

<script type="text/html" id="caozuo">
    <button class="layui-btn" lay-event="themeEvent">选择主题</button>
</script>
<script>

    var local_store = layui.data("local_store");
    var local = local_store.token;
    $.ajax({
        type:"get",
        url:"/admin/station/query/stationLoginQuanxXian?stationId="+json.id,
        dataType: "json",
        contentType:"application/json;charset=utf-8",
        beforeSend: function(request) {
            request.setRequestHeader("token", local);
        },
        success:function (res) {
            if(res.code==500){
                alert("权限不足")
                location="../../admin/main.html";
                return
            }}})
    function GetRequest() {
        var url = decodeURI(location.search); //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for(var i = 0; i < strs.length; i ++) {
                theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }

    var json=GetRequest();

    var pages= localStorage.getItem('page');

    layui.use(['laydate', 'form', 'table'], function () {

        var $ = layui.$;
        var laydate = layui.laydate;
        var form = layui.form;
        var table = layui.table;

        table.render({
            elem: "#groupdata",
            url: "/admin/group/query/groupAll?groupStationId="+json.id,
            id: "t",
            type:'get',
            toolbar:"#tol",
            cols: [[{
                title: "分组编号",
                field: "group_id",
                width: "15%",
                align: "center"
            },
                {
                    title: "分组名称",
                    field: "group_name",
                    width: "15%",
                    align: "center"
                }
                ,   {
                    title: "所属站点",
                    field: "station_name",
                    width: "15%",
                    align: "center"
                },
                {
                    title: "所选主题",
                    field: "group_desktop_configuration",
                    width: "15%",
                    align: "center"
                }
                ,
                {
                    title: "状态",
                    field: "group_status",
                    width: "15%",
                    align: "center"
                },
                {
                    title: "操作",
                    width: "24%",
                    align: "center",
                    toolbar: "#caozuo"
                }
            ]],page:{
                curr:pages
            },
            done: function (res, curr, count1) {
                localStorage.setItem('page',curr);
                $("#zong").html(count1);
            }

        })

        //    删除的监听事件
        table.on("tool(groupdata)", function (obj) {
            var getdata = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）

            switch (layEvent) {
                case "themeEvent":
                    layui.data("s",{key:"group",value:getdata});
                    layui.data("station_ss",{key:"station_ids",value:json})
                    layer.open({
                        title:"选择主题",
                        type:2,
                        content:'/admin/station_config/views/layui/themeXuanZe.html',
                        area:['800px','500px']
                    });
                    break;
            }
        });
    });

    /**
     * 设置cookie
     * @param name
     * @param value
     * @constructor
     */
    function Setcookie (name, value)
    {
        document.cookie = name+"="+value+";path=#/layui/groupedit";

        //即document.cookie= name+"="+value+";path=/";   时间可以不要，但路径(path)必须要填写，因为JS的默认路径是当前  页，如果不填，此cookie只在当前页面生效！~
    }
</script>
<!--分页-->
<script>
    layui.use(['laypage', 'layer'], function(){
        var laypage = layui.laypage
            ,layer = layui.layer;

        //完整功能
        // laypage.render({
        //     elem: 'demo7'
        //     ,count: 100
        //     ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
        //     ,jump: function(obj){
        //         console.log(obj)
        //     }
        // });
        //将一段数组分页展示

    });
</script>


